unit RSTabel_System;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dRoot, DB, StdCtrls, Buttons, ExtCtrls, ComCtrls, dxSkinsCore,
  dxSkinBlack, dxSkinBlue, dxSkinCaramel, dxSkinCoffee, dxSkinDarkSide,
  dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin,
  dxSkinSilver, dxSkinStardust, dxSkinSummer2008, dxSkinsDefaultPainters,
  dxSkinValentine, dxSkinXmas2008Blue, Menus, cxLookAndFeelPainters,
  cxButtons, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit,
  cxButtonEdit, cxRadioGroup, dxSkinscxPCPainter, cxGraphics, cxCheckBox,
  cxDropDownEdit, cxCalendar, cxLookupEdit, cxDBLookupEdit,
  cxDBLookupComboBox, dxdbtrel, IBCustomDataSet, IBQuery, cxPC;

type
  TfmRSTabel_System = class(TdlgRoot)
    cxPageControl1: TcxPageControl;
    tsCreate: TcxTabSheet;
    tsEdit: TcxTabSheet;
    dsSotr: TDataSource;
    qSotr: TIBQuery;
    qSotrPID: TIntegerField;
    qSotrPP: TIBStringField;
    qSotrSDNAME: TIBStringField;
    qSotrSDID: TIntegerField;
    Panel2: TPanel;
    Label6: TLabel;
    rbIndivid: TcxRadioButton;
    rbGroup: TcxRadioButton;
    ltvOsnPodr: TdxLookupTreeView;
    lcbPedag: TcxDBLookupComboBox;
    cxDateEdit1: TcxDateEdit;
    cbMKW0: TcxCheckBox;
    bCreate: TcxButton;
    qOsnPodr: TIBQuery;
    qOsnPodrSDPARID: TIntegerField;
    qOsnPodrSDID: TIntegerField;
    qOsnPodrSDNAME: TIBStringField;
    dsqOsnPodr: TDataSource;
    qTree: TIBQuery;
    qTreeLIST_SDID: TMemoField;
    qUsluga: TIBQuery;
    IntegerField1: TIntegerField;
    IntegerField2: TIntegerField;
    IBStringField1: TIBStringField;
    dsqUsluga: TDataSource;
    qDopPodr: TIBQuery;
    dsqDopPodr: TDataSource;
    qDopPodrSDNAME: TIBStringField;
    lcbDopPodr: TcxLookupComboBox;
    qDopPodrSDID: TIntegerField;
    lcbUsluga: TcxLookupComboBox;
    procedure rbGroupClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure lcbUslugaPropertiesCloseUp(Sender: TObject);
    procedure lcbDopPodrPropertiesCloseUp(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmRSTabel_System: TfmRSTabel_System;

implementation
uses dbinv, InvTypes, InvProc, Filter;
{$R *.dfm}

procedure TfmRSTabel_System.rbGroupClick(Sender: TObject);
begin
  inherited;
  qUsluga.Close;
  if rbGroup.Checked then
    qUsluga.ParamByName('sdparid').AsInteger := 14149
  else
    qUsluga.ParamByName('sdparid').AsInteger := 14150;
  qUsluga.Open;
  qDopPodr.Close;
  qDopPodr.Open;
end;

procedure TfmRSTabel_System.FormShow(Sender: TObject);
begin
  inherited;
  qOsnPodr.Close;
  qOsnPodr.Open;
  rbGroupClick(rbGroup);
  qSotr.Open;
  qSotr.Locate('pid', gUserID, []);
  lcbPedag.Text := qSotrPP.AsString;
  qTree.Close;
  qTree.Open;
end;

procedure TfmRSTabel_System.lcbUslugaPropertiesCloseUp(Sender: TObject);
begin
  inherited;
  qUsluga.Locate('sdid', lcbUsluga.EditValue, []);
end;

procedure TfmRSTabel_System.lcbDopPodrPropertiesCloseUp(Sender: TObject);
begin
  inherited;
    qDopPodr.Locate('sdid', lcbDopPodr.EditValue, []);
end;

end.

